package com.sd.cti.api;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 模版渲染
 */
public abstract class Render {
    protected String view;
    protected HttpServletRequest request;
    protected HttpServletResponse response;
    private static String encoding = "UTF-8";
    private static boolean devMode = false;

    public Render() {
    }

    static void init(String encoding, boolean devMode) {
        Render.encoding = encoding;
        Render.devMode = devMode;
    }

    public static String getEncoding() {
        return encoding;
    }

    public static boolean getDevMode() {
        return devMode;
    }

    public Render setContext(HttpServletRequest request, HttpServletResponse response) {
        this.request = request;
        this.response = response;
        return this;
    }

    public Render setContext(HttpServletRequest request, HttpServletResponse response, String viewPath) {
        this.request = request;
        this.response = response;
        if (this.view != null && this.view.length() > 0 && this.view.charAt(0) != '/') {
            this.view = viewPath + this.view;
        }

        return this;
    }

    public String getView() {
        return this.view;
    }

    public void setView(String view) {
        this.view = view;
    }

    public abstract void render();
}

